Skip to content

Only call reformat if necessary#2191

Merged
WyattBlue merged 1 commit intoPyAV-Org:mainfrom
lgeiger:no-reformatter
Mar 12, 2026
Merged

Only call reformat if necessary#2191
WyattBlue merged 1 commit intoPyAV-Org:mainfrom
lgeiger:no-reformatter

Conversation

@lgeiger
Copy link
Contributor

@lgeiger lgeiger commented Mar 12, 2026

This prevents the need for constructing a VideoReformatter for cases where frame.to_ndarray() is called without arguments:

import av
import numpy as np
frame = av.VideoFrame(1920, 1080, format="rgb24")
%timeit frame.to_ndarray()

Before:

1.75 μs ± 10.4 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

After:

1.39 μs ± 2.76 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)

@WyattBlue WyattBlue merged commit 1088b71 into PyAV-Org:main Mar 12, 2026
6 checks passed
@lgeiger lgeiger deleted the no-reformatter branch March 12, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants